package genreate;

import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : ReflectDemo
 * @Author : 54061
 * @Date: 2022/2/11 18:49
 */
public class ReflectDemo {
    public static void main(String[] args) throws Exception{
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        //泛型是编译阶段的类型约束
        //list.add("Hello);
        System.out.println("list = " + list);

        Class clazz = list.getClass();


        Method add = clazz.getDeclaredMethod("add",Object.class);


        add.invoke(list,"Hello");
        add.invoke(list,new Student());
        System.out.println("list = " + list);

    }
}
